package mshop.com.schild_kotlin.entitys

import android.os.Parcel
import android.os.Parcelable

/**
 * Created by mayi on 2018/5/23.
 * @Autor CaiWF
 * @Email 401885064@qq.com
 * @TODO
 */

data class HotBean(
        val itemList: List<ItemList>,
        val count: Int,
        val total: Int,
        val nextPageUrl: String,
        val adExist: Boolean
)

data class ItemList(
        val type: String,
        val data: Data,
        val tag: String,
        val id: Int,
        val adIndex: Int
)


data class Data(
        val dataType: String,
        val id: Int,
        val title: String,
        val description: String,
        val library: String,
        val tags: List<Tag>,
        val consumption: Consumption,
        val resourceType: String,
        val slogan: String,
        val provider: Provider,
        val category: String,
        val author: Author,
        val cover: Cover,
        val playUrl: String,
        val thumbPlayUrl: Any,
        val duration: Long,
        val webUrl: WebUrl,
        val releaseTime: Long,
        val playInfo: List<PlayInfo>,
        val campaign: Any,
        val waterMarks: Any,
        val adTrack: Any,
        val type: String,
        val titlePgc: Any,
        val descriptionPgc: Any,
        val remark: Any,
        val ifLimitVideo: Boolean,
        val searchWeight: Int,
        val idx: Int,
        val shareAdTrack: Any,
        val favoriteAdTrack: Any,
        val webAdTrack: Any,
        val date: Long,
        val promotion: Any,
        val label: Any,
        val labelList: List<Any>,
        val descriptionEditor: String,
        val collected: Boolean,
        val played: Boolean,
        val subtitles: List<Any>,
        val lastViewTime: Any,
        val playlists: Any,
        val src: Any
)

data class PlayInfo (
        val height: Int,
        val width: Int,
        val urlList: List<Url>,
        val name: String,
        val type: String,
        val url: String
) : Parcelable {
    constructor(parcel: Parcel) : this(
            parcel.readInt(),
            parcel.readInt(),
            parcel.createTypedArrayList(Url),
            parcel.readString(),
            parcel.readString(),
            parcel.readString()) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeInt(height)
        parcel.writeInt(width)
        parcel.writeTypedList(urlList)
        parcel.writeString(name)
        parcel.writeString(type)
        parcel.writeString(url)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<PlayInfo> {
        override fun createFromParcel(parcel: Parcel): PlayInfo {
            return PlayInfo(parcel)
        }

        override fun newArray(size: Int): Array<PlayInfo?> {
            return arrayOfNulls(size)
        }
    }
}

data class Url (
        val name: String,
        val url: String,
        val size: Int
) : Parcelable {
    constructor(parcel: Parcel) : this(
            parcel.readString(),
            parcel.readString(),
            parcel.readInt()) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(name)
        parcel.writeString(url)
        parcel.writeInt(size)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<Url> {
        override fun createFromParcel(parcel: Parcel): Url {
            return Url(parcel)
        }

        override fun newArray(size: Int): Array<Url?> {
            return arrayOfNulls(size)
        }
    }
}

data class Tag(
        val id: Int,
        val name: String,
        val actionUrl: String,
        val adTrack: Any,
        val desc: String,
        val bgPicture: String,
        val headerImage: String,
        val tagRecType: String
)

data class Provider(
        val name: String,
        val alias: String,
        val icon: String
)

data class Consumption(
        val collectionCount: Int,
        val shareCount: Int,
        val replyCount: Int
)

data class Cover (
        val feed: String,
        val detail: String,
        val blurred: String,
        val sharing: String,
        val homepage: String
)

data class WebUrl(
        val raw: String,
        val forWeibo: String
)

data class Author (
        val id: Int,
        val icon: String,
        val name: String,
        val description: String,
        val link: String,
        val latestReleaseTime: Long,
        val videoNum: Int,
//        val adTrack: String,
        val follow: Follow,
//        val shield: Shield,
        val approvedNotReadyVideoCount: Int,
        val ifPgc: Boolean
) : Parcelable {
    constructor(parcel: Parcel) : this(
            parcel.readInt(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readLong(),
            parcel.readInt(),
            parcel.readParcelable(Follow::class.java.classLoader),
            parcel.readInt(),
            parcel.readByte() != 0.toByte()) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeInt(id)
        parcel.writeString(icon)
        parcel.writeString(name)
        parcel.writeString(description)
        parcel.writeString(link)
        parcel.writeLong(latestReleaseTime)
        parcel.writeInt(videoNum)
        parcel.writeParcelable(follow, flags)
        parcel.writeInt(approvedNotReadyVideoCount)
        parcel.writeByte(if (ifPgc) 1 else 0)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<Author> {
        override fun createFromParcel(parcel: Parcel): Author {
            return Author(parcel)
        }

        override fun newArray(size: Int): Array<Author?> {
            return arrayOfNulls(size)
        }
    }
}

data class Shield (
        val itemType: String,
        val itemId: Int,
        val shielded: Boolean
)

data class Follow (
        val itemType: String,
        val itemId: Int,
        val followed: Boolean
) : Parcelable {
    constructor(parcel: Parcel) : this(
            parcel.readString(),
            parcel.readInt(),
            parcel.readByte() != 0.toByte()) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(itemType)
        parcel.writeInt(itemId)
        parcel.writeByte(if (followed) 1 else 0)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<Follow> {
        override fun createFromParcel(parcel: Parcel): Follow {
            return Follow(parcel)
        }

        override fun newArray(size: Int): Array<Follow?> {
            return arrayOfNulls(size)
        }
    }
}